package com.example.controller;

import com.example.pojo.SuperUser;
import com.example.service.SuperUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 名称SuperUserController
 * 描述
 *
 * @version 1.0
 * @author:wanghao
 * @datatime:2023,04,16,17,34
 */
@Controller
public class SuperUserController {
    @Autowired
    SuperUserService superUserService;


    @RequestMapping("/SuperUserLoginPage")
    public String SuperUerLoginPage(){return "SuperUserLoginPage";}

    @ResponseBody
    @RequestMapping("/SuperUserLogin")
    public String CheckSuperUserPasswd(@RequestParam(value = "name")String name,@RequestParam(value = "passwd")String passwd){
        if(superUserService.CheckSuperUerPasswd(name,passwd).equals("true"))    return "Succeed";
        else return "something wrong";
    }

    @RequestMapping("RegisterSuperUserPage")
    public String RegisterSuperUserPage(){return "RegisterSuperUserPage";}

    @RequestMapping("RegisterSuperUser")
    @ResponseBody
    public String RegisterSuperUser(SuperUser superUser){
        int i =superUserService.InsertSuperUser(superUser);
        if (i>0)    return "Succeed";
        else return "something wrong";
    }
}
